<template>
	<view>
		<view v-if="loaded || list.itemIndex < 15" class="uni-indexed-list__title-wrapper">
			<text v-if="list.items && list.items.length > 0" class="uni-indexed-list__title">{{ list.key }}</text>
		</view>

		<view v-if="(loaded || list.itemIndex < 15) && list.items && list.items.length > 0" class="uni-indexed-list__list">
			<view v-for="(item, index) in list.items" :key="index" class="uni-indexed-list__item"
				hover-class="uni-indexed-list__item--hover">
				<view class="uni-indexed-list__item-container" @click="onClick(idx, index)">

					<view class="left">
						<image style="width: 100upx; height: 100upx;" mode="aspectFill" :src="photoImg"></image>
					</view>
					<view class="center">
						<view class="uni-indexed-list__item-content">{{ item.name }}s AI as smart as its AI as smart as its AI as
							smart as it</view>
						<view class="uni-indexed-list__item-content_sub">s AI as smart as its AI as smart as its AI as smart as its
							AI as smart as it</view>
					</view>
					<view class="right">
						Cancel
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import photoImg from '@/static/photo.png'
	export default {
		name: 'UniIndexedList',
		emits: ['itemClick'],
		data() {
			return {
				photoImg
			}
		},
		props: {
			loaded: {
				type: Boolean,
				default: false
			},
			idx: {
				type: Number,
				default: 0
			},
			list: {
				type: Object,
				default () {
					return {}
				}
			},
			showSelect: {
				type: Boolean,
				default: false
			}
		},
		methods: {
			onClick(idx, index) {
				this.$emit("itemClick", {
					idx,
					index
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.uni-indexed-list__list {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		gap: 6upx;
		padding-left: 20upx;
	}

	.uni-indexed-list__item {
		font-size: 14px;
		border-radius: 20upx;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex: 1;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		background-color: #fff;
	}

	// 要改造的容器
	.uni-indexed-list__item-container {
		padding: 20upx;
		flex: 1;
		display: flex;
		position: relative;
		align-items: center;
		display-direction: row;

		.left {
			height: 100upx;
			width: 100upx;
		}

		.center {
			padding-left: 20upx;
			flex: 1;
			overflow: hidden;
			text-overflow: ellipsis;
			flex-wrap: nowrap;
			min-width: 0;

			.uni-indexed-list__item-content {
				font-size: 14px;
				font-weight: 600;
				height: 22px;
				overflow: hidden;
				color: #333;
			}

			.uni-indexed-list__item-content_sub {
				font-size: 13px;
				color: #999;
				height: 20px;
				overflow: hidden;
				text-overflow: ellipsis;
			}
		}

		.right {
			width: 140upx;
			background-color: #333;
			color: #fff;
			font-size: 28upx;
			text-align: center;
			padding: 6upx 0;
			border-radius: 30upx;
		}
	}






	.uni-indexed-list {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
	}

	.uni-indexed-list__title-wrapper {
		/* #ifndef APP-NVUE */
		display: flex;
		width: 100%;
		/* #endif */
		padding-left: 20upx;
	}

	.uni-indexed-list__title {
		padding: 6px 12px;
		line-height: 24px;
		font-size: 16px;
		font-weight: 500;
	}
</style>